package org.lifei.gift.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import org.lifei.gift.domain.Employee;
import org.lifei.gift.mapper.EmployeeMapper;
import org.lifei.gift.service.IEmployeeService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.lifei.query.EmployeeQuery;
import org.lifei.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lifei
 * @since 2024-03-23
 */
@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements IEmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;

    @Override
    public PageList<Employee> pageQUery(EmployeeQuery query) {
        //封装分页对象
        Page<Employee> page = new Page<>(query.getPage(), query.getRows());
        //获取查询结果
        List<Employee> employees = employeeMapper.pageQUery(page, query.getKeyword());
        //把查询结果封装成我们自己的分页对象
        return new PageList<Employee>(page.getTotal(),employees);
    }
}
